home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / hugearr.zip / HUGEARR.H < prev    next >
C/C++ Source or Header  |  1992-04-02  |  4KB  |  99 lines

  1. /* Include file for HUGEARR.DLL modules. */
  2.  
  3. #ifndef _HUGEARR_H
  4. #define _HUGEARR_H
  5.  
  6. #include "sjslib.h"
  7.  
  8. /* Possible return values for huge array functions. */
  9. #define HA_OK              0
  10. #define HA_OUTOFMEMORY    -1
  11. #define HA_TOOMANYARRAYS  -2
  12. #define HA_SUBSCRIPT      -4
  13. #define HA_BADARRAY       -5
  14. #define HA_FILEOPENERROR  -7
  15. #define HA_FILEWRITEERROR -8
  16. #define HA_FILEREADERROR  -9
  17.  
  18. /* VBG: Global Const HA_OK             =  0 */
  19. /* VBG: Global Const HA_OUTOFMEMORY    = -1 */
  20. /* VBG: Global Const HA_TOOMANYARRAYS  = -2 */
  21. /* VBG: Global Const HA_SUBSCRIPT      = -4 */
  22. /* VBG: Global Const HA_BADARRAY       = -5 */
  23. /* VBG: Global Const HA_FILEOPENERROR  = -7 */
  24. /* VBG: Global Const HA_FILEWRITEERROR = -8 */
  25. /* VBG: Global Const HA_FILEREADERROR  = -9 */
  26.  
  27. /* Structure describing each individual huge array. */
  28. typedef struct HugeDesc
  29.     {
  30.     HANDLE  handle;   /* handle to global memory array */
  31.     int     recsize;  /* record size of array */
  32.     long    ubound;   /* upper bound of array */
  33.     int     perseg;   /* #elements per segment */
  34.     } HUGEDESC;
  35.  
  36. typedef HUGEDESC *PHUGEDESC;  /* Make type for pointer to huge array description structure. */
  37. typedef double    currency;   /* currency and double are the same size and will be treated the same */
  38.  
  39. /* VBG: Type HugeDesc */
  40. /* VBG:     handle As Integer */
  41. /* VBG:     recsise As Integer */
  42. /* VBG:     ubound As Long */
  43. /* VBG:     perseg As Integer */
  44. /* VBG: End Type */
  45.  
  46. extern HANDLE hLocalMem;
  47. extern int    NumArrays;
  48.  
  49. extern int      FAR PASCAL VBHugeDim(int recsize, long ubound);
  50. extern int      FAR PASCAL VBHugeRedim(int hArray, long ubound);
  51. extern int      FAR PASCAL VBHugeGet(int hArray, long element, LPBYTE buffer);
  52. extern int      FAR PASCAL VBHugeGetNum(int hArray, long element, int nelem, LPBYTE buffer);
  53. extern int      FAR PASCAL VBHugeSet(int hArray, long element, LPBYTE buffer);
  54. extern int      FAR PASCAL VBHugeSetNum(int hArray, long element, int nelem, LPBYTE buffer);
  55. extern int      FAR PASCAL VBHugeErase(int hArray);
  56. extern int      FAR PASCAL VBHugeNumArrays(VOID);
  57. extern long     FAR PASCAL VBHugeUbound(int hArray);
  58. extern int      FAR PASCAL VBHugeGetInt(int hArray, long element);
  59. extern long     FAR PASCAL VBHugeGetLong(int hArray, long element);
  60. extern float    FAR PASCAL VBHugeGetSingle(int hArray, long element);
  61. extern double   FAR PASCAL VBHugeGetDouble(int hArray, long element);
  62. extern currency FAR PASCAL VBHugeGetCurrency(int hArray, long element);
  63. extern long     FAR PASCAL VBHugeSave(int hArray, long nelements, int OutLen, LPSTR FileSpec);
  64. extern long     FAR PASCAL VBHugeLoad(int hArray, int InLen, LPSTR FileSpec);
  65.  
  66. /* Macro to calculate byte offset of an array element given its number, the size of each element,
  67.    and the number of elements per segment. */
  68. #define HugeElementOffset(ELEMNO, PERSEG, RECSIZE)    \
  69.       (ELEMNO) / (long) (PERSEG) * 0x10000L        \
  70.     + (ELEMNO) % (long) (PERSEG) * (long) (RECSIZE)
  71.  
  72. /* Macro to decrement the array handle (since VB users think handles begin with 1), then check
  73.    if it is within the valid range. */
  74. #define DecCheckHandle(HARRAY)                \
  75.     /* VB users think hArray begins at 1 */        \
  76.     if (--(HARRAY) < 0 || (HARRAY) >= NumArrays)    \
  77.         /* illegal array handle */        \
  78.         return HA_BADARRAY;
  79.  
  80. /* Macro to return error if specified array has not yet been allocated. */
  81. #define CheckNotAllocYet(PARRAY)            \
  82.     if ((PARRAY) -> handle == NULL)            \
  83.         {                    \
  84.         /* array hasn't been allocated */    \
  85.         LocalUnlock(hLocalMem);            \
  86.         return HA_BADARRAY;            \
  87.         }
  88.  
  89. /* Macro to return error if specified array element is out of bounds. */
  90. #define CheckSubscript(PARRAY, ELEMENT, MAX)        \
  91.     if ((PARRAY)->ubound < (MAX) || (ELEMENT) < 0)    \
  92.         {                    \
  93.         /* subscript out of range */        \
  94.         LocalUnlock(hLocalMem);            \
  95.         return HA_SUBSCRIPT;            \
  96.         }
  97.  
  98. #endif
  99.